package org.yt.dao.base;

import java.util.List;

public class Page {

	public Integer total ;  //总记录数
	public Integer pageSize; //每页显示记录数
	public Integer currentPage = 1; //当前页码
	public Integer next;      //下一页
	public Integer forward;   //上一页
	public Integer totalPage; //总页数
	public List<Object> result; //结果集
	public Integer start; //开始记录数
	
	public Page(Integer pageSize,Integer currentPage,Integer total){
		 this.pageSize=pageSize; 
		 this.total = total; 
		 this.start = (currentPage -1) * pageSize;
		 totalPage = total/pageSize; 
	     int mod=(int) (total%pageSize); 
	     if(mod>0 || totalPage == 0){
	    	 totalPage++;
	     }
	}

	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}

	public Integer getForward() {
		if(currentPage == 1){
			return currentPage;
		}
		return currentPage - 1;
	}

	public void setForward(Integer forward) {
		this.forward = forward;
	}

	public Integer getNext() {
		if(getTotalPage() == currentPage){
			return currentPage;
		}
		return currentPage + 1;
	}

	public void setNext(Integer next) {
		this.next = next;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public List<Object> getResult() {
		return result;
	}

	public void setResult(List<Object> result) {
		this.result = result;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public Integer getTotalPage() {
		 totalPage = total/pageSize; 
	     int mod=(int) (total%pageSize); 
	     if(mod>0 || totalPage == 0){
	    	 totalPage++;
	     }
		return totalPage;
	}

	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}

	public Integer getStart() {
		return (currentPage -1) * pageSize;
	}

	public void setStart(Integer start) {
		this.start = start;
	}
	
	
}
